<template>
  <div class="main">
    <el-container class="wrapper">
      <el-aside :width="isCollapse ? '60px' : '220px'" class="aside">
        <!-- 将属性传递给子组件 -->
        <mainMenu :is-fold="isCollapse" />
      </el-aside>
      <el-container>
        <el-header height="60px" class="header">
          <mainHeader @fold-change="handleFoldChange"
        /></el-header>
        <el-main class="main-content">
          <!-- 菜单中的路由跳转时的占位 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import mainHeader from '@/components/main-header/main-header.vue'
import mainMenu from '@/components/main-menu/main-menu.vue'

// 定义变量来存储折叠的状态
const isCollapse = ref(false)

// 处理子组件传递的折叠事件
function handleFoldChange(isFold: boolean) {
  // 记录状态
  isCollapse.value = isFold
}
</script>

<style lang="less" scoped>
.main {
  height: 100%;
}
.wrapper {
  height: 100%;
  .aside {
    background-color: #01132c;
    overflow-x: hidden;
    overflow-y: auto;
    cursor: pointer;
    transition: width 0.2s ease;
    &::-webkit-scrollbar {
      display: none;
    }
  }
  .header {
    // background-color: aqua;
    height: 50px;
  }
  .main-content {
    overflow-x: hidden;
    background-color: #f0f2f5;
  }
}
</style>
